package com.example.demo.mapper;

import com.example.demo.entity.Student;
import com.example.demo.entity.User;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author longzhonghua
 * @data 2/19/2019 8:21 PM
 */
@Mapper
@Repository
public interface StudentMapper {

    @Select("SELECT * FROM student WHERE id = #{id}")
    Student queryUserById(@Param("id") String id);

    @Select("SELECT password FROM student WHERE id = #{id}")
    String queryPasswordById(@Param("id") String id);

    @Select("SELECT password FROM student WHERE name = #{name}")
    String queryPasswordByName(@Param("name") String name);


    @Select("SELECT * FROM student limit 1000")
    List<User> queryAll();

    @Insert({"INSERT INTO student(name,id) VALUES(#{name},#{id})"})
    int add(Student student);

    //应该用不上
    @Delete("DELETE FROM student WHERE id = #{id} CASCADE")
    int delById(int id);
    //应该用不上
    @Update("UPDATE student SET name=#{name} WHERE id = #{id} CASCADE")
    int updateById(Student student);

    //不会用
    @Select("SELECT * FROM student limit 1000")
    Page<User> getUserList();
}
